
module.exports = app => {

    return class HomeController extends app.Controller {

        async index() {

            let member = await this.service.member.get();

            await this.ctx.render('member/index.js', {
                member
            });
        }

        async info() {
            await this.ctx.render('member/info/index.js');
        }

        async editName() {
            await this.ctx.render('member/index.js');
        }

        async editAddress() {
            await this.ctx.render('member/address/index.js');
        }

        async dynamic() {
            await this.ctx.render('member/dynamic/index.js');
        }

        async intro() {
            await this.ctx.render('member/intro/index.js');
        }

        // async guardian() {
        //     let guardian = await this.service.guardian.list({
        //         studentId: '6ad3aea3226c41c89a4e8c1085994719'
        //     });
        //     await this.ctx.render('member/guardian/index.js', {
        //         guardian
        //     });
        // }

        async children() {
            let children = await this.service.guardian.getChildren();
            await this.ctx.render('member/children/index.js', {
                children
            });
        }

        async teacher() {
            await this.ctx.render('member/teacher/index.js');
        }

        /**
         * 设置默认孩子
         * @returns {Promise<void>}
         */
        async setDefaultChildren(){
            let params = this.ctx.request.query;
            await this.service.member.setDefaultChildren(params);
            this.success();
        }



    };
};
